home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / c / pro24 / box.c < prev    next >
Encoding:
Text File  |  1987-06-29  |  3.5 KB  |  110 lines

  1. /*
  2.  *
  3.  * Short driver module
  4.  *
  5.  */
  6.  
  7. main()
  8. {
  9.         clrscr();
  10.         box(1,1,23,79);
  11.         box(2,2,21,77);
  12.         box(3,3,19,75);
  13.         box(4,4,17,73);
  14.         box(5,5,15,71);
  15.         box(6,6,13,69);
  16.         box(7,7,11,67);
  17.         box(8,8,9,65);
  18.         box(9,9,7,63);
  19.         box(10,10,5,61);
  20.         box(11,11,3,59);
  21.         box(12,12,1,57);
  22.         poscur(24,1);
  23. }
  24.  
  25. /************************************************************
  26.  *                      BOX                                 *
  27.  *----------------------------------------------------------*
  28.  *   Written by:        Jeff Ebert    7/01/87               *
  29.  *   Modified by:       xxxxxxxxxx                          *
  30.  *                                                          *
  31.  *   Please modify me!                                      *
  32.  *   Possible Enhancements include but are not limited to:  *
  33.  *     1) Variable box character styles  [1 line or 2]      *
  34.  *     2) Error checking                                    *
  35.  *     3) Color options                                     *
  36.  *                                                          *
  37.  *                                                          *
  38.  *   This function builds a simple double frame for a menu. *
  39.  *   The function is passed the parameters for the upper    *
  40.  *   left corner row, upper left corner column the height   *
  41.  *   of the frame and the width.                            *
  42.  *                                                          *
  43.  ************************************************************/
  44. #include    <stdio.h>
  45.  
  46. #define                 ULCOR                   201
  47. #define                 URCOR                   187
  48. #define                 LLCOR                   200
  49. #define                 LRCOR                   188
  50. #define                 VBAR                    186
  51. #define                 HBAR                    205
  52. #define                 ESC                     27
  53.  
  54.  
  55. box(row, col, hgt, wdth)
  56. int row, col, hgt, wdth;
  57.  
  58. {
  59.         int x, y;
  60.  
  61.         poscur(row,col);
  62.         putchar(ULCOR);
  63.         for(x = col + 1; x <=(col + wdth -1); x++)
  64.           putchar(HBAR);
  65.         putchar(URCOR);
  66.  
  67.         for(x = row + 1; x <=(row + hgt - 1); x++){
  68.           poscur(x,col);
  69.           putchar(VBAR);
  70.           poscur(x,col+wdth);
  71.           putchar(VBAR);
  72.         }
  73.         poscur(x,col);
  74.         putchar(LLCOR);
  75.         for(x= col + 1; x <=(col + wdth -1); x++)
  76.        putchar(HBAR);
  77.         putchar(LRCOR);
  78. }
  79.  
  80. /********************************************************
  81.  *            POSCUR                *
  82.  *------------------------------------------------------*
  83.  *  This function positions the cursor at the specified    *
  84.  * x,y coordinate.  It uses the ANSI standard ESCAPE     *
  85.  * sequence to produce the desired effect.  Its not the *
  86.  * fastest way to position the cursor, but perhaps the     *
  87.  * most portable.                    *
  88.  *                            *
  89.  ********************************************************/
  90. poscur(xcor,ycor)
  91. int xcor,ycor;
  92. {    
  93.     printf("%c[%d;%dH",ESC,xcor,ycor);
  94. }
  95.  
  96.  
  97. /********************************************************
  98.  *            CLRSCR                *
  99.  *------------------------------------------------------*
  100.  *  This function positions the cursor at the specified    *
  101.  * x,y coordinate.  It uses the ANSI standard ESCAPE     *
  102.  * sequence to produce the desired effect.  Its not the *
  103.  * fastest way to position the cursor, but perhaps the     *
  104.  * most portable.                    *
  105.  *                            *
  106.  ********************************************************/
  107. clrscr()
  108. {    
  109.     printf("%c[2J",ESC);
  110. }